package com.itheima.exerciseTest.test50_59;

import java.io.*;

/*
    利用字节流将E盘下的a.png图片复制到D盘下(文件名保存一致)(什么盘无所谓)
 */
public class Test56 {
    public static void main(String[] args) {
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;

        try {
            bis = new BufferedInputStream(new FileInputStream("D:\\Picture\\常德风格.jpg"));
            bos = new BufferedOutputStream(new FileOutputStream("D:\\Picture\\测试\\常德风格.jpg"));

            byte[] bytes = new byte[1024];
            int len;
            while((len = bis.read(bytes)) != -1){
                bos.write(bytes,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(bis != null){
                try {
                    bis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(bos != null){
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
